# The main entry point of this application.

import os
import wx
import locale
import gettext
import i18n
from javavatask.gui import MainFrame, MyTaskBarIcon
from javavatask.storage import getLanguage

def initI18n():
    """Initialize the i18n setting of the application.
    """
    
    # Load language setting from preference setting first.
    language = getLanguage()
    
    # If the user doesn't set the specific language, then use the default 
    # language of the operating system.
    if not language:
        language = locale.getdefaultlocale()[0]
    print 'Language:', language
    
    os.environ.setdefault('LC_ALL', language)
    gettext.install(i18n.domain, i18n.localedir, unicode=True)
    #gettext.translation(i18n.domain, i18n.localedir, languages=['en_US']).install(True)


class App(wx.App):
    def OnInit(self):
        frame = MainFrame()
        self.SetTopWindow(frame)
        frame.Show()
        return True

if __name__ == '__main__':
    # Initialize the i18n setting.
    initI18n()
    
    # Startup the application.
    app = App(False)
    app.MainLoop()
